package com.fm.demo.jpush

import android.content.Context
import android.os.Bundle
import android.os.PersistableBundle

import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity

/**
 * @CreateData: 2019/11/1 16:21
 * @E-Mail: 709674174@qq.com
 * @Author: lyy
 * @Description: 极光推送，跳转页面基类
 */
abstract class BaseJPushActivity : AppCompatActivity() {
    protected lateinit var mContext: Context

    /**
     * 获取页面layout
     *
     * @return layout id
     */
    @get:LayoutRes
    protected abstract val layoutId: Int

    override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
        super.onCreate(savedInstanceState, persistentState)
        setContentView(layoutId)
        mContext = this
        initView(savedInstanceState)
        initData()
    }

    /**
     * 初始化view
     *
     * @param savedInstanceState 异常关闭保存页面数据
     */
    protected abstract fun initView(savedInstanceState: Bundle?)

    /**
     * 初始化数据
     */
    protected fun initData() {}


}
